FROM node:lts-slim AS worker
WORKDIR /
COPY entrypoint.sh /app/entrypoint.sh
RUN sed -i "s/deb.debian.org/mirrors.ustc.edu.cn/g" /etc/apt/sources.list.d/debian.sources \
    && apt-get update \
    && apt-get upgrade -y \
    && apt-get install -y git dos2unix \
    && apt-get autoremove \
    && apt-get clean
RUN npm config set registry=https://registry.npmmirror.com \
    && npm install -g npm \
    && npm i -g pm2 \
    && git config --global --add safe.directory '*' \
    && git config --global pull.rebase false \
    && git config --global user.email "lx@lxmusic.cn" \
    && git config --global user.name "lx" \
    && dos2unix /app/entrypoint.sh \
    && chmod +x /app/entrypoint.sh \
    && rm -rf /var/cache/* \
    && rm -rf /tmp/*
EXPOSE 9527
ENV PORT=9527 \
    BIND_IP='0.0.0.0' \
    CONFIG_PATH='/config/config.js' \
    LOG_PATH='/logs' \
    DATA_PATH='/data'
ENTRYPOINT ["/app/entrypoint.sh"]